﻿#include "widget_about.h"
#include "ui_widget_about.h"
#include "global_define.h"
#include <QDebug>
#include <QEvent>
#include <QKeyEvent>
#include <QDesktopServices>

widget_about::widget_about(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::widget_about)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_QuitOnClose,false);
    setWindowTitle(tr("关于"));

    QFont iniFont;
    iniFont.setFamily("黑体");



#if OEM
//    ui->label_logo->setPixmap(QPixmap(":/myImage/images/LOGO.png"));

    ui->label_version->setFont(iniFont);
    ui->label_version->setText(tr(SOFEWARENAMEOEM) + VERSION);

    ui->label_copyright_c->setFont(iniFont);
    ui->label_copyright_c->setText(tr(" "));

    ui->label_copyright->setFont(iniFont);
    ui->label_copyright->setText(" ");

//    ui->label_logo_text->setPixmap(QPixmap(":/myImage/images/logoTxt.png"));
//    ui->label_logo_text->installEventFilter(this);
#else
    ui->label_logo->setPixmap(QPixmap(":/myImage/images/LOGO.png"));

    ui->label_version->setFont(iniFont);
    ui->label_version->setText(tr(SOFEWARENAME) + VERSION);

    ui->label_copyright_c->setFont(iniFont);
    ui->label_copyright_c->setText(tr("版权所有 ©2014 深圳市博锐捷数控技术有限公司 保留所有权利。"));

    ui->label_copyright->setFont(iniFont);
    ui->label_copyright->setText("Copyright 2014 SHEN ZHEN BRJ CNC TECHNOLOGY Co.,Ltd . All rights reserved.");

    ui->label_logo_text->setPixmap(QPixmap(":/myImage/images/logoTxt.png"));
    ui->label_logo_text->installEventFilter(this);
#endif
}

widget_about::~widget_about()
{
    delete ui;
}

bool widget_about::eventFilter(QObject *o, QEvent *e)
{
    if (e->type() == QEvent::MouseButtonPress) {
        QDesktopServices::openUrl(QUrl("http://www.brjcnc.com"));
        return true;
    } else {
        return QWidget::eventFilter(o, e);
    }
}

void widget_about::on_pushButton_clicked()
{
    close();
}
